<template>
  <a-layout id="components-layout-demo-side" style="min-height: 100vh">
    <a-layout-sider collapsible v-model="collapsed" style="width:300px">
      <div class="logo">
        <img src="../assets/logo.png" alt=""/><br/>
        <p class="logotxt">合众易成微信推广系统</p></div>
      <!-- 主导航 -->
      <a-menu theme="dark" :defaultSelectedKeys="['1']" mode="inline">
        <a-sub-menu key="1">
          <span slot="title"><a-icon type="tags" /><span>活动管理</span></span>
          <a-menu-item key="2">
            <router-link :to="{path:'/actmanage'}"><a-icon type="tag" />活动维护</router-link></a-menu-item>
        </a-sub-menu>
        <a-sub-menu key="3">
          <span slot="title"><a-icon type="team" /><span>商家管理</span></span>
          <a-menu-item key="4">
            <router-link :to="{path:'/company'}"><a-icon type="user" />入驻商家查询</router-link></a-menu-item>
        </a-sub-menu>
      </a-menu>
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0" >
         <a-row>
          <a-col :span="6" :offset="18" class="logout">
            <router-link to='/login'>退出登录</router-link>
          </a-col>
        </a-row>
      </a-layout-header>
      <a-layout-content style="margin: 0 16px">
        <!-- 面包屑导航 -->
        <a-row>
          <a-col :span="8">
            <a-breadcrumb :routes="routes" class="bread">
              <template slot="itemRender" slot-scope="{route, params, routes, paths}">
                <span v-if="routes.indexOf(route) === routes.length - 1">
                  首页 / {{route.breadcrumbName}}
                </span>
                <router-link v-else :to="paths.join('/')">
                  {{route.breadcrumbName}}
                </router-link>
              </template>
            </a-breadcrumb>
          </a-col>
        </a-row>
        <div :style="{ padding: '24px', background: '#fff', minHeight: '360px' }">
          <router-view />
        </div>
      </a-layout-content>
      <a-layout-footer style="text-align: center">
        Ant Design ©2018 Created by Ant UED
      </a-layout-footer>
    </a-layout>
  </a-layout>
</template>
<script>
// 活动信息
const ru =  [ {
  path: '/actmanage',
  breadcrumbName: '活动维护'
}, {
  path: '/company',
  breadcrumbName: '商家管理'
}];
export default {
  data(){
    return{
     routes: [],
     collapsed: false
    }
  },
  mounted(){
    this.changePath();
  },
  methods: {
    changePath(){
      this.routes = ru;
      let r = this.routes.filter((v)=>{
        return v.path == this.$route.path;
      });
      this.routes = r;
    }
  },
  watch:{
    $route(){
      this.changePath();
    }
  }
}
</script>
<style lang='less' scoped>
/* layout布局 */
#components-layout-demo-side .logo {
    margin: 16px;
    color: #fff;
}
.logo img{
  width: 32px;
  height: 32px;
}
.logotxt{
  padding: 10px 0;
}
.logout{
  text-align: right;
  padding-right: 20px;
}
// 面包屑
.bread{
  text-align: left;
    padding: 10px 0;
}
</style>
